<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>js方法测试</title>
</head>
<body>
    <script>

        let i = 5;
        i+= 2;
        console.log('i',i);
        
        // var a= function(a){
        //     console.log(a);
            
        // }

        // a(1);


        //js中的闭包操作
        function createCounter(){
            let count=0;
            return function(){
                count ++;
                return count;
            }

        }

        const counter = createCounter();  //创建计数器实例
        console.log(typeof counter);
        
        console.log(counter());
        console.log(counter());
        console.log(counter());
     
        

//         function createCounter() {  
//     let count = 0; // 初始化计数器为0  
//     return function() { // 返回一个内部函数，形成闭包  
//         count++; // 递增计数器  
//         return count; // 返回递增后的值  
//     };  
// }  
  
// const counter = createCounter(); // 创建计数器实例  
// console.log(counter()); // 输出: 1  
// console.log(counter()); // 输出: 2


let result = {
    
    b: '2'
}

if(result.a==='1'){
    console.log('成功');
    
}
if(result.a==='2'){
    console.log('失败');
    
}



let a = '2', b='2';

console.log(.1);

let test1 = "12";
console.log('test1',Number(test1));

function arr1 (a=0,b=1){
    console.log('ab',a,b);
    
}
arr1();
let num = 2;
console.log('sss', typeof String(num));

let aaa = "fsd.sdf"
console.log('aa',aaa.split('.')[0]);

    </script>
</body>
</html>